package com.coincalf.admin.config;

import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.MultipartConfigElement;

/**
 * Create Time: 2018年05月21日 10:28
 * C@author lxl
 **/
@Configuration
@ConfigurationProperties(prefix = "img.alias")
@Data
@Accessors(chain = true)
public class ImageConfig {

    // http://beiw.oss-cn-shenzhen.aliyuncs.com
    //阿里云API的外网域名
    @Value("${img.alias.oss.endpoint}")
    public String ENDPOINT;// = "http://oss-cn-shenzhen.aliyuncs.com";
    //阿里云API的密钥Access Key ID
    @Value("${img.alias.oss.access_key_id}")
    public String ACCESS_KEY_ID;//= "LTAIPOVHFuZNEnq2";
    //阿里云API的密钥Access Key Secret
    @Value("${img.alias.oss.access_key_secret}")
    public String ACCESS_KEY_SECRET;//= "IqtVByqQAIjbBRM8etCQrSMxx7L1Oh";
    //阿里云API的bucket名称
    @Value("${img.alias.oss.backet_name}")
    public String BACKET_NAME;//= "beiw";
    //阿里云API的文件夹名称 要以/结尾
    @Value("${img.alias.oss.folder}")
    public String FOLDER;//="coincalf/";

    /**
     * 自己服务器图片存放地址
     */
    @Value("${img.alias.my.ulr}")
    public String COMMON_FILE_URL;//="D:/coincalf/";


    @Bean
    public MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        factory.setMaxFileSize(10 * 1024 * 1024);
        return factory.createMultipartConfig();
    }
}
